<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <meta name="renderer" content="webkit"/>
  <meta name="force-rendering" content="webkit"/>
  <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"/>
  <title>渠道设置</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
  <link rel="stylesheet" href="/bower_components/bootstrap/dist/css/bootstrap.min.css">
  <link rel="stylesheet" href="/bower_components/font-awesome/css/font-awesome.min.css">
  <link rel="stylesheet" href="/bower_components/Ionicons/css/ionicons.min.css">
  <link rel="stylesheet" href="/bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css">
  <link rel="stylesheet" href="/dist/css/AdminLTE.min.css">
  <link rel="stylesheet" href="/dist/css/skins/_all-skins.min.css">

  <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
  <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  <!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  <![endif]-->

  <!-- Google Font -->
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">

  <!--头部-->
  <header id="headerDiv" class="main-header">
    <!--#include  file="/pages/admin/header.html"-->
  </header>

  <!--左侧边栏 -->
  <aside id="sidebarDiv" class="main-sidebar">
    <!--#include  file="/pages/admin/sidebar.html"-->
  </aside>

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        <small>编辑渠道</small>
      </h1>
      <ol class="breadcrumb">
        <li><i class="fa fa-group"></i> 渠道管理</li>
        <li><a href="javascript:goBack();">渠道列表</a></li>
        <li><a href="javascript:void (0);">编辑渠道</a></li>
      </ol>

    </section>

    <!-- Main content -->
    <section class="content">
      <div class="row">
        <div class="col-xs-12">
          <div class="nav-tabs-custom">
            <div class="tab-content">
              <div class="active tab-pane" id="basic">
                <form id="dataform" class="form-horizontal">
                  <div class="form-group">
                    <label for="username" class="col-sm-2 control-label">站长名称：</label>
                    <div class="col-sm-5">
                      <p id="username"></p>
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="id" class="col-sm-2 control-label">站长ID：</label>
                    <div class="col-sm-5">
                      <p id="pid"></p>
                      <input type="hidden" class="form-control" id="id" name="id">
                    </div>
                  </div>

                  <div class="form-group">
                    <label for="lyid" class="col-sm-2 control-label">联运渠道ID：</label>
                    <div class="col-sm-2">
                      <input type="text" class="form-control" id="lyid" name="lyid" placeholder="联运平台渠道id">
                    </div>
                  </div>

                  <div class="form-group">
                    <label for="password" class="col-sm-2 control-label">新密码：</label>
                    <div class="col-sm-5">
                      <input type="text" class="form-control" id="password" name="password">
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="repassword" class="col-sm-2 control-label">确认密码：</label>
                    <div class="col-sm-5">
                      <input type="text" class="form-control" id="repassword">
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="service_id" class="col-sm-2 control-label">隶属客服：</label>
                    <div class="col-sm-5">
                      <select class="form-control" id="service_id" name="service_id">
                        <option value="0">请选择</option>
                      </select>
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="email" class="col-sm-2 control-label">电子邮件：</label>
                    <div class="col-sm-5">
                      <input type="text" class="form-control" id="email" name="email">
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="realname" class="col-sm-2 control-label">真实姓名：</label>
                    <div class="col-sm-5">
                      <input type="text" class="form-control" id="realname" name="realname">
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="qq" class="col-sm-2 control-label">QQ：</label>
                    <div class="col-sm-5">
                      <input type="text" class="form-control" id="qq" name="qq">
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="tel" class="col-sm-2 control-label">电话：</label>
                    <div class="col-sm-5">
                      <input type="text" class="form-control" id="tel" name="tel">
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="idcard" class="col-sm-2 control-label">身份证：</label>
                    <div class="col-sm-5">
                      <input type="text" class="form-control" id="idcard" name="idcard">
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="bankname" class="col-sm-2 control-label">收款银行：</label>
                    <div class="col-sm-2">
                      <select id="bankname" name="bankname" class="form-control">
                        <option value="中国银行">中国银行</option>
                        <option value="农业银行">农业银行</option>
                        <option value="工商银行">工商银行</option>
                        <option value="建设银行">建设银行</option>
                        <option value="交通银行">交通银行</option>
                        <option value="招商银行">招商银行</option>
                        <option value="支付宝">支付宝</option>
                      </select>
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="bankbranch" class="col-sm-2 control-label">开户分行：</label>
                    <div class="col-sm-5">
                      <input type="text" class="form-control" id="bankbranch" name="bankbranch">
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="accountname" class="col-sm-2 control-label">收款姓名：</label>
                    <div class="col-sm-5">
                      <input type="text" class="form-control" id="accountname" name="accountname">
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="bankaccount" class="col-sm-2 control-label">收款账号：</label>
                    <div class="col-sm-5">
                      <input type="text" class="form-control" id="bankaccount" name="bankaccount">
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="province" class="col-sm-2 control-label">省份：</label>
                    <div class="col-sm-5">
                      <input type="text" class="form-control" id="province" name="province">
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="city" class="col-sm-2 control-label">城市：</label>
                    <div class="col-sm-5">
                      <input type="text" class="form-control" id="city" name="city">
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="recommend" class="col-sm-2 control-label">推荐人：</label>
                    <div class="col-sm-5">
                      <input type="text" class="form-control" id="recommend" name="recommend">
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="count" class="col-sm-2 control-label">已发展下线：</label>
                    <div class="col-sm-5">
                      <p><span id="count"></span><span>个</span><a onclick="getByRecommend()">查询名下会员</a></p>
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="count" class="col-sm-2 control-label">注册：</label>
                    <div class="col-sm-5">
                      <p>IP:  <span id="regip"></span><br/>时间:<span  id="create_time"></span></p>
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="count" class="col-sm-2 control-label">最近登录：</label>
                    <div class="col-sm-5">
                      <p>IP:  <span id="login_ip"></span><br/> 时间:<span  id="login_time"></span></p>
                    </div>
                  </div>
                  <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                      <button  onclick="sumbitForm();" type="button" class="btn btn-danger">保存设置</button>
                    </div>
                  </div>
                </form>
              </div>
            </div>
          </div>
        </div>
      </div>
    </section>
  </div>
  <!--底部-->
  <footer id="footerDiv" class="main-footer">
    <!--#include  file="/pages/admin/footer.html"-->
  </footer>

  <!-- Control Sidebar -->
  <!-- /.control-sidebar -->
  <!-- Add the sidebar's background. This div must be placed
       immediately after the control sidebar -->
  <div class="control-sidebar-bg"></div>
</div>
<script src="/bower_components/jquery/dist/jquery.min.js"></script>
<script src="/bower_components/morris.js/morris.min.js"></script>
<script src="/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="/bower_components/datatables.net/js/jquery.dataTables.min.js"></script>
<script src="/bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
<script src="/bower_components/jquery-slimscroll/jquery.slimscroll.min.js"></script>
<script src="/bower_components/fastclick/lib/fastclick.js"></script>
<script src="/dist/js/adminlte.min.js"></script>
<script src="/dist/js/store.min.js"></script>

<script src="/dist/js/layer/layer.js"></script>

<script>
    $(function () {
        let id = store.get("id");
        if(id == null){
            window.location.href = "/pages/webmaster/list.html";
            return;
        }
        let url="/lmgame/webmaster/getById";
        $.ajax({
            type : 'POST',
            url : url,
            data : {
                "id":id
            },
            dataType : "json",
            success: function(data) {
                if(data.code!=0){
                    layer.msg(data.msg);
                    window.location.href = "/index.html";
                    return;
                }
                let html = "";
                data.data.slist.forEach(function(key){
                    html+="<option value="+key.id+">"+key.username+"</option>";
                });
                $("#service_id").html(html);
                $("#pid").html(data.data.webmaster.id);
                $("#id").val(data.data.webmaster.id);
                $("#lyid").val(data.data.webmaster.lyid);
                $("#username").html(data.data.webmaster.username);
                $("#service_id").val(data.data.webmaster.serviceid);
                $("#email").val(data.data.webmaster.email);
                $("#realname").val(data.data.webmaster.realname);
                $("#qq").val(data.data.webmaster.qq);
                $("#tel").val(data.data.webmaster.tel);
                $("#idcard").val(data.data.webmaster.idcard);
                $("#bankname").val(data.data.webmaster.bankname);
                $("#bankbranch").val(data.data.webmaster.bankbranch);
                $("#accountname").val(data.data.webmaster.accountname);
                $("#bankaccount").val(data.data.webmaster.bankaccount);
                $("#province").val(data.data.webmaster.province);
                $("#city").val(data.data.webmaster.city);
                $("#recommend").val(data.data.webmaster.recommend);
                $("#regip").html(data.data.webmaster.regip);
                $("#create_time").html(data.data.webmaster.create_time);
                $("#login_ip").html(data.data.webmaster.login_ip);
                $("#login_time").html(data.data.webmaster.login_time);
                $("#count").html(data.data.count);
            },
            error: function(xhr, ts, et) { //XMLHttpRequest, textStatus, errorThrown
                if (xhr.status === 400) {
                    window.location.href = "/pages/admin/login.html";
                }
                if (xhr.status === 403) {
                    window.location.href = "/403.html";
                }
            }
        });
    });

    function sumbitForm() {
        let id = $("#id").html();
        let lyid = $("#lyid").val();
        let service_id = $("#service_id").val();
        let email = $("#email").val();
        let realname = $("#realname").val();
        let qq = $("#qq").val();
        let tel = $("#tel").val();
        let idcard = $("#idcard").val();
        let bankname = $("#bankname").val();
        let bankbranch = $("#bankbranch").val();
        let accountname = $("#accountname").val();
        let bankaccount = $("#bankaccount").val();
        let province = $("#province").val();
        let city = $("#city").val();
        let recommend = $("#recommend").val();
        let dataMap = {};

        let url="/lmgame/webmaster/update";
        $.ajax({
            type : 'POST',
            url : url,
            data : $("#dataform").serialize(),
            dataType : "json",
            success: function(data) {
                if(data.code!=0){
                    layer.msg(data.msg);
                    return;
                }
                window.location.href = "/pages/webmaster/list.html";
            },
            error: function(xhr, ts, et) { //XMLHttpRequest, textStatus, errorThrown
                if (xhr.status === 400) {
                    window.location.href = "/pages/admin/login.html";
                }
                if (xhr.status === 403) {
                    window.location.href = "/403.html";
                }
            }
        });
    }

    function getByRecommend() {
        let id = $("#id").val();
        store.set("recommend",id);
        window.location.href = "list.html";
    }

    function  goBack() {
        window.history.back(-1);
    }
</script>
</body>
</html>
